<?php
/**
 * @name /www/unit-tests/ItemSearchWidget.php
 * @author Michael Foss <michael@mikefoss.com>
 * @version 2011.04.02
 *
 * Unit test for ItemSearchWidget class.
 */

// Sets up configuration settings and includes libraries.
require_once('_ini.php');
// Libraries
ReqLib('/lib/private/ItemSearchWidget.php');

function DefineHeader() {
?><style type="text/css">
  code {
    font: bold 10pt 'Courier New';
    color: #666;
    background-color: #CCC;
    border: 3px solid #666;
    padding: 4px 6px;
    margin: 10px 20px;
    display: block;
  }
  form, ul, ol {
    margin: 0px 20px;
  }
  a#Back {
    float: right;
    margin: 10px;
    padding: 4px 6px;
    border: 1px solid #666;
    background-color: #CCC;
  }
</style><?
}

/**
 * Defines page content.
 *
 */
function DefineContent() {
  // Page content goes here.
  ?>
<h1><a href="ItemSearchWidget.php">ItemSearchWidget - Unit Test</a></h1>
<a id="Back" href="index.php">Back to Unit Testing Home</a>
<?
  $isw = new ItemSearchWidget();
  $isw->DisplayWidget();
  if (isset($_GET['q']))
    DoAction($isw);
}

function DoAction(&$isw) {
?><hr />
<p>
<?
  $items = $isw->GetFilteredSearchResults();
  foreach ($items as $item)
    println(htmlspecialchars($item->Name) . '<br />');
?></p>
<?
}

// Launches the page; without this, nothing happens.
require_once('_loader.php');